<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <img src="1.gif" alt="" width="55">
    <div>上午好</div>
    <script>
        let img = document.querySelector('img');
        let div = document.querySelector('div');
        //得到当前的小时数
        let date = new Date();
        let h = date.getHours();
        //判断小时数改变图片和文字信息
        if (h < 12) {
            img.src = '1.gif';
            div.innerHTML = '上午好呀';
        } else if (h < 18) {
            img.src = '640.gif';
            div.innerHTML = '下午好呀';
        } else {
            img.src = '640.gif';
            div.innerHTML = '晚上好呀';
        }

    </script>
</body>

</html>